home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 13 / AMIGAplus Sonderheft 13 (1998)(ICP)(DE)[!].iso / rexx / fd2pragma.filer < prev    next >
Text File  |  1993-11-26  |  4KB  |  129 lines

  1. /*
  2.     $VER: FD2Pragma.filer 1.1 (26.11.93)
  3.  
  4.     Author:
  5.         Michael Böhnisch (billy@uni-paderborn.de)    (mb)
  6.  
  7.     Function:
  8.         Create  files  with  SAS/C  #pragma statements from library
  9.         function  description files (#?.fd).  Automagically chooses
  10.         "standard" file name for target file.
  11.  
  12.     Requires:
  13.         SAS/C fd2pragma tool (SC:C/fd2pragma)
  14.  
  15.     Call:
  16.         fd2pragma
  17.  
  18.         (no  parameters,  operates  on  selected  files  in Filer's
  19.         source window)
  20.  
  21.     Example for "Filer.RC":
  22.         XBUTTON 3,3,0,1,"fd2pragma","fd2pragma"
  23.  
  24.     History:
  25.         05.10.1993    1.0 Initial Release (mb)
  26.         26.11.1993    1.1 Review for Filer 3.10 Gamma 2 (mb)
  27. */
  28.  
  29. OPTIONS RESULTS            /* aquire results            */
  30.  
  31. /* -------------------------------------------------------------------- */
  32.  
  33. fdcmd      = 'SC:C/fd2pragma'    /* conversion command to call        */
  34. fdtail     = '_lib.fd'        /* fname suffix for validity check    */
  35. fdtaillen  = LENGTH( fdtail )
  36. pragmasuff = '_pragmas.h'    /* suffix to replace fdtail        */
  37.  
  38. /* -------------------------------------------------------------------- */
  39.  
  40. text1 =    "is no fd file or has wrong name.|"
  41. text1 = text1 || "Continue anyway?"
  42.  
  43. text2 = "Name of header file to create?"
  44. text2 = text2 || " (`" || pragmasuff || "´ is appended automagically)"
  45.  
  46. /* -------------------------------------------------------------------- */
  47.  
  48. ADDRESS 'FilerRexx'        /* default to Filer's AReXX port    */
  49.  
  50. PANEL OFF            /* deactivate Filer's GUI buttons    */
  51.  
  52. /* -------------------------------------------------------------------- */
  53. /* get source directory name, append "/" if it is not a device name    */
  54. /* -------------------------------------------------------------------- */
  55.  
  56. GETSOURCEPATH
  57. srcdir = RESULT
  58. IF RIGHT( srcdir, 1 ) ~= ":" THEN srcdir = srcdir || "/"
  59.  
  60. /* -------------------------------------------------------------------- */
  61. /* get target directory name, append "/" if it is not a device name    */
  62. /* -------------------------------------------------------------------- */
  63.  
  64. GETTARGETPATH
  65. tgtdir = RESULT
  66. IF RIGHT( tgtdir, 1 ) ~= ":" THEN tgtdir = tgtdir || "/"
  67.  
  68. GETNUMENTRIES            /* get number of source entries        */
  69. numentries = RESULT
  70.  
  71. DO i = 1 TO numentries        /* loop through all entries        */
  72.   GETNAME i            /* get ith entry            */
  73.   entry = RESULT
  74.  
  75.   type = LEFT( entry, 1 )    /* parse filetype (f, d, F, D)        */
  76.   name = SUBSTR( entry, 2 )    /* parse filename            */
  77.  
  78.   SELECT
  79.  
  80.     WHEN type = 'f' THEN DO    /* if entry is a selected file...    */
  81.  
  82.     /* ---------------------------------------------------------------- */
  83.     /* do a validity check on the filename, consult user on        */
  84.     /* failure                                */
  85.     /* ---------------------------------------------------------------- */
  86.  
  87.       IF RIGHT( name, fdtaillen ) ~= fdtail THEN DO
  88.         txt1 = name || "|" || text1
  89.         QUESTBOX txt1
  90.         IF RESULT = 1 THEN DO
  91.           SETSTRING name
  92.           GETSTRING text2
  93.           IF RESULT ~= 'RESULT' THEN DO
  94.             node = RESULT
  95.             CALL Convert 
  96.           END
  97.         END
  98.       END
  99.       ELSE DO
  100.         node = SUBSTR( name, 1, LENGTH( name ) - fdtaillen )
  101.         CALL Convert
  102.       END
  103.  
  104.       TOGGLEENTRY i
  105.     END /* WHEN */
  106.  
  107.     WHEN type = 'd' THEN    /* if entry is a directory...        */
  108.       TOGGLEENTRY i        /* de-select and ignore            */
  109.  
  110.     OTHERWISE            /* ignore entries not selected        */
  111.  
  112.   END /* SELECT */
  113. END /* DO i */
  114.  
  115. UPDATETARGETDIR            /* re-read Filer's dest window        */
  116. PANEL ON            /* activate buttons            */
  117. EXIT                /* voilá!                */
  118.  
  119. /* -------------------------------------------------------------------- */
  120. /* Subroutine "Convert":                        */
  121. /*    Create History entry for filer, execute conversion command    */
  122. /* -------------------------------------------------------------------- */
  123.  
  124.  
  125. Convert:
  126.     HISTORY "fd2pragma" srcdir||name "-->" tgtdir||node||pragmasuff
  127.     SHELL COMMAND fdcmd srcdir||name tgtdir||node||pragmasuff
  128.     RETURN
  129.